package com.cc.controller;

import com.cc.entity.CstCustomer;
import com.cc.service.ICustomerService;
import com.github.pagehelper.Page;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 新梦想.陈超
 * @version 2021.2
 * @Description: {TODO}
 * @date 2022/5/26 下午2:29
 */
@Controller
@RequestMapping("customer")
public class CustomerController {
    @Resource
    private ICustomerService iCustomerService;
    
    @RequiresRoles(value = {"营销经理"})
    @RequestMapping("list")
    public String list(@RequestParam(value = "page",defaultValue = "1") int page,
                                  @RequestParam(value = "pageSize",defaultValue = "10")int pageSize,
                                  Model model){
        //TODO 1.调用service查询数据
        Page<CstCustomer> customerPage = iCustomerService.list(page);
        //TODO 2.绑定数据
        model.addAttribute("customerPage",customerPage);
        //TODO 3.放回view
        return "~cust/cust/list";
    }
}
